package Test;

import officeserver.users.AccessLevel;
import officeserver.users.Address;
import officeserver.users.PersonalInfo;
import junit.framework.TestCase;
/**
 * 
 * @author Chris Bayruns
 *
 */
public class testUpdatePersonalInfo extends TestCase
{

	public void testUpdateInfo()
	{
		PersonalInfo testInfo = new PersonalInfo(AccessLevel.PATIENT);
		PersonalInfo update = new PersonalInfo(AccessLevel.PATIENT);
		//(int streetNumber, String road, int zipCode, String state)
		update.setAddress(new Address(123, "fake st", 30332, "GA" ));
		update.setEmail(null);
		update.setFirstName(null);
		update.setLastName(null);
		update.setUsername(null);
		testInfo.updateInfo(update);
		assertEquals("unknown", testInfo.getEmail());
		assertEquals("user0", testInfo.getFirstName());
		assertEquals("user0", testInfo.getLastName());
		assertEquals("user0", testInfo.getUsername());
		assertEquals("123 fake st\n30332, GA", testInfo.getAddressString());
		
		update.setAddress(null);
		update.setEmail("bob@microsoft.com");
		update.setFirstName(null);
		update.setLastName(null);
		update.setUsername(null);
		
		testInfo.updateInfo(update);
		assertEquals("bob@microsoft.com", testInfo.getEmail());
		assertEquals("user0", testInfo.getFirstName());
		assertEquals("user0", testInfo.getLastName());
		assertEquals("user0", testInfo.getUsername());
		assertEquals("123 fake st\n30332, GA", testInfo.getAddressString());
		
		update.setAddress(null);
		update.setEmail(null);
		update.setFirstName("Bob");
		update.setLastName(null);
		update.setUsername(null);
		
		testInfo.updateInfo(update);
		assertEquals("bob@microsoft.com", testInfo.getEmail());
		assertEquals("Bob", testInfo.getFirstName());
		assertEquals("user0", testInfo.getLastName());
		assertEquals("user0", testInfo.getUsername());
		assertEquals("123 fake st\n30332, GA", testInfo.getAddressString());
		
		update.setAddress(null);
		update.setEmail(null);
		update.setFirstName(null);
		update.setLastName("Barker");
		update.setUsername(null);
		
		testInfo.updateInfo(update);
		assertEquals("bob@microsoft.com", testInfo.getEmail());
		assertEquals("Bob", testInfo.getFirstName());
		assertEquals("Barker", testInfo.getLastName());
		assertEquals("user0", testInfo.getUsername());
		assertEquals("123 fake st\n30332, GA", testInfo.getAddressString());
		
		update.setAddress(null);
		update.setEmail(null);
		update.setFirstName(null);
		update.setLastName(null);
		update.setUsername("bbarker");
		
		testInfo.updateInfo(update);
		assertEquals("bob@microsoft.com", testInfo.getEmail());
		assertEquals("Bob", testInfo.getFirstName());
		assertEquals("Barker", testInfo.getLastName());
		assertEquals("bbarker", testInfo.getUsername());
		assertEquals("123 fake st\n30332, GA", testInfo.getAddressString());
		
		testInfo.updateInfo(null);
		assertEquals("bob@microsoft.com", testInfo.getEmail());
		assertEquals("Bob", testInfo.getFirstName());
		assertEquals("Barker", testInfo.getLastName());
		assertEquals("bbarker", testInfo.getUsername());
		assertEquals("123 fake st\n30332, GA", testInfo.getAddressString());
	}

}
;